﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UtilsBase
{
    public class UtilsProcess
    {
        public string executeBashCommand(string command)
        {
            var process = new Process
            {
                StartInfo = new ProcessStartInfo("/bin/bash", "")
            };
            process.StartInfo.RedirectStandardInput = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.UseShellExecute = false;
            process.Start();
            process.StandardInput.WriteLine(command);
            process.StandardInput.Close();
            var cpuInfo = process.StandardOutput.ReadToEnd();
            process.WaitForExit();
            process.Dispose();
            return cpuInfo;
            //var lines = cpuInfo.Split('\n');
            //foreach (var item in lines)
            //{
            //    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").ToString() + " ：" + item);
            //}
        }
    }
}
